package com.example.myapplication.fragment;

import android.os.Bundle;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.ListView;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.myapplication.MainActivity;
import com.example.myapplication.R;
import com.example.myapplication.adapter.Myadapter;
import com.example.myapplication.adapter.Myadapter1;
import com.example.myapplication.bean.GetJsonDataUtil;
import com.example.myapplication.bean.Mates;
import com.google.gson.Gson;

import java.util.List;


/**
 * Created by Administrator on 2020/12/15.
 */

public class Fragment1 extends Fragment {

    private ListView listView1;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment1,container,false);
        listView1 = view.findViewById(R.id.listview1);
        String jsonData = new GetJsonDataUtil().getJson(getActivity(),"data2.json");
        Gson gson = new Gson();
        //映射关系
        Mates mates = gson.fromJson(jsonData, Mates.class);
        List<Mates.ResultBean.MatesBean> fh = mates.getResult().getMates();
        listView1.setAdapter(new Myadapter1(getActivity(),fh));



        return view;
    }
}